#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	char a[500002];
	memset(a, '\0', sizeof(a));
	gets(a);
	int i = 0;
	int count = 0;
	while (a[i] != '\0')
	{
		i++;
		if (a[i] != ' ' && a[i] != '\0' && (a[i + 1] == ' ' || a[i + 1] == '\0'))
		{
			count++;
		}
	}
	if (count == 1)
	{
		for (int k = 0; k < i; k++)
		{
			if (a[k] != ' ')
			{
				putchar(a[k]);
			}
		}
		return 0;
	}
	while (count)
	{

		while (a[i] != ' ' && i > 0)
		{
			i--;
		}
		if (i == 0)
		{
			putchar(a[0]);
		}
		int tmp = i;
		i = i + 1;

		while (a[i] != '\0')
		{
			putchar(a[i]);
			i++;
		}
		if (count > 1)
		{
			putchar(' ');
		}

		//Hello World   Here I Come
		while (a[tmp - 1] == ' ')
		{
			tmp--;
		}
		a[tmp] = '\0';
		i = tmp;
		count--;

	}


	return 0;
}